<?php $this->import('Header') ?>
<div class="container single">
	<div class="row">
		<div class="col-xs-2 menu">
			<?php $this->import('Single/Left') ?>
		</div>
		<div class="col-xs-10">
			<div class="article">
				<div class="well well-sm dog-info">
					<p class="bg-title title">
						<span><?php echo ($article) ? '编辑' : '发帖' ?></span>
					</p>
					<form class="form-inline add-article" id="js-article-edit">
						<input type="hidden" name="articleId" value="<?php echo isset($article['ArticleId']) ? $article['ArticleId'] : 0 ?>" />
						<div class="form-group full">
							<label>分类：</label>
							<select class="form-control" id="js-c1">
								<option value="">请选择分类</option>
								<?php foreach ($categories as $category) {?>
									<option value="<?php echo $category['CategoryId'] ?>"><?php echo $category['CategoryName'] ?></option>
								<?php } ?>
							</select>
							<select class="form-control" id="js-c2">
								<option value="">请选择分类</option>
							</select>
							<div id="js-category-data" style="display: none;">
								<?php foreach ($categories as $category) { ?>
									<select categoryId="<?php echo $category['CategoryId'] ?>">
										<option value="">请选择分类</option>
										<?php foreach ($category['List'] as $val) { ?>
											<option value="<?php echo $val['CategoryId'] ?>"><?php echo $val['CategoryName'] ?></option>
										<?php } ?>
									</select>
								<?php } ?>
							</div>
						</div>
						<div class="form-group full">
							<label>标题：</label>
							<input type="text" value="<?php echo isset($article['Title']) ? $article['Title'] : ''; ?>" name="title" class="form-control title-input" />
						</div>
						<div class="form-group full">
							<textarea class="" id="content" name="content"><?php echo isset($article['Content']) ? $article['Content'] : ''; ?></textarea>
						</div>
						<div id="js-error-box"></div>
						<div class="form-group full btn-group">
							<button type="reset" class="btn btn-default">取消</button> &nbsp;
							<button type="submit" class="btn btn-danger"><?php echo ($article) ? '保存' : '发布' ?></button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<?php $this->import('Footer') ?>
<script>
	seajs.init({
		userBreedName: '<?php echo $userBreedName; ?>',
		defaultCategoryId: <?php echo isset($article['CategoryId']) ? $article['CategoryId'] : 0 ?>
	});
</script>